 class FieldValidator {
     constructor(txtId, valifunc) {
         this.input = $('#' + txtId);
         this.p = this.input.nextElementSibling;
         //失去焦点的时候调用这个验证函数
         this.valifunc = valifunc;
         //  console.log(this.input, this.p)
         this.input.onblur = () => {
             this.validate();

         }

     }
     async validate() {
         const err = await this.valifunc(this.input.value);
         if (err) {
             this.p.innerText = err;
             return false
         } else {
             this.p.innerText = '';
             return true;
         }
     }
     static async validate(...arr) {
         const resp = arr.map(n => n.validate());
         const result = await Promise.all(resp);
         return result.every(n => n);
     }
 }